package kr.hkit.androidcomplete01.ch06;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.location.GpsStatus.Listener;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class SetParameter extends Activity {
	Button mLeft;
	Button mRight;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setparameter);
		
		mLeft=(Button) findViewById(R.id.btnleft);
		mRight=(Button) findViewById(R.id.btnright);
	/*}*/	
/*		public void mOnClick(View v){
			switch(v.getId()){
			case R.id.btnleft : 
				setParam(3,1);
				break;
			case R.id.btnright:
				setParam(1,3);
				break;			
			}
		}*/
	
		
/*		mLeft.setOnClickListener(listener);
		mRight.setOnClickListener(listener);*/
		
		mLeft.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				setParam(3,1); 
			}
		});
		mRight.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				setParam(1,3);
			}
		});
	}	
	
	View.OnClickListener listener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.btnleft : 
				setParam(3,1);
				break;
			case R.id.btnright:
				setParam(1,3);
				break;
			}
		}
	};
		void setParam(int left, int right){
			LinearLayout.LayoutParams lparam = (LinearLayout.LayoutParams)mLeft.getLayoutParams();
			lparam.weight = left;
			mLeft.setLayoutParams(lparam);

			LinearLayout.LayoutParams rparam = (LinearLayout.LayoutParams)mRight.getLayoutParams();
			rparam.weight = right;
			mRight.setLayoutParams(rparam);
			
		}
}

